<template>
	<view>
		<scroll ref="mescrollRef" @init="mescrollInit" :down="downOption" @down="downCallback" :up="upOption" @up="upCallback"
		 @emptyclick="emptyClick">
			<stop isBack>
				<view slot="content">日志总览</view>
			</stop>
			<view class="pad2 bcf">
				<search v-model="text" placeholder="关键词搜索" @search="doSearch()" class="tac"></search>
			</view>
			<view class="flrc bc13">
				<view class="flex1 pad3">
					<scondition @input="reload()" model="CimingReportType" v-model="where.eq.type" label="选择日志类型"></scondition>
				</view>
				<view class="flex1 pad3">
					<scondition @input="reload()" model="Job" v-model="where.eq['user.jobs.id']" label="选择岗位"></scondition>
				</view>
				
			</view>
			<view class="lh2">
				<view class="bdbdo pos-r mar2 bcf round3 shadow-blur bdso" 
				v-for="item in data" :key="log.id">
					<view class="flrc bg-grey light pad2 fs16">
						<!-- <view class="wh15-15 round bdso">
							<image :src="pic(item.user.pic)" mode="aspectFill" class="wh15-15 round bdso"></image>
						</view> -->
						<!-- <view class="padl10 flex1">
							<view class="fs14">{{item.user.name}}</view>
							<view class="flex-r flex-start fs8 mart3">
								<view class="line-cyan cu-btn sm round1 marr1" v-for="job in item.user.jobs">{{job.name}}</view>
								<view class="line-cyan cu-btn sm round1 marr1" v-show="item.user.jobs == 0">岗位未定</view>
							</view>
						</view> -->
						<view class="fa fa-user-circle op7 marr3"></view>
						<view class="fs16 flex1">{{item.user.name}}</view>
						<view class="flex-r flex-start fs8">
							岗位：
							<!-- line-green cu-btn sm round1 marl1 -->
							<view class="fwb" v-for="job in item.user.jobs">{{job.name}}</view>
							<view class="fwb" v-show="item.user.jobs == 0">岗位未定</view>
						</view>
					</view>
					<!-- 总结 -->
					<view class="mart3 padl3">
						<view class="list-style-2 fwb">总结</view>
						<view v-for="row,index in item.summary" class="flex-r flex-start pad2 pos-r">
							<text class="fwb wh10-10 flcc bg-green round3 op8">{{index+1}}.</text>
							<view class="flex1">
								<view class="padl2">进度：{{row[1]}}</view>
								<view class="padl2 c11 op7">内容：{{row[0]}}</view>
							</view>
						</view>
						<view class="mar2 pad3 bdso tac" v-show="item.summary.length == 0">内容未填写</view>
					</view>
					<!-- 计划 -->
					<view class="mart3 padl3">
						<view class="list-style-2 fwb">计划</view>
						<view v-for="row,index in item.plan" class="flex-r flex-start pad2 pos-r">
							<text class="fwb wh10-10 flcc bg-orange round3 op8">{{index+1}}.</text>
							<view class="flex1">
								<view class="padl2 ">进度：{{row[1]}}</view>
								<view class="padl2 c11 op7">内容：{{row[0]}}</view>
							</view>
						</view>
						<view class="mar2 pad3 bdso tac" v-show="item.plan.length == 0">内容未填写</view>
					</view>
					<view class="c12 pad2 flrc bdtda">
						<view class="flex1 c11">{{datetime(item.createAt)}}</view>
						<view class="c11 fs10">{{item.type.name}}</view>
					</view>
					<ripple></ripple>
				</view>
			</view>
			<loading :loading="myIsLoading"></loading>
		</scroll>
	</view>
</template>

<script>
	import List from '../../../assets/js/list.js'
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins:[MescrollMixin],
		data() {
			let list = new List()
			return {
				list,
				data:[],
				where:{
					eq:{
						type:'',
						'user.jobs.id':''
					}
				}
			}
		},
		methods: {
				reload() {
					this.showLoading()
					this.list.setData({
						_order: {
							id: "DESC"
						},
						_where:this.where,
						_search:this.text,
						_g:['report','user','job'],
						_range:['all']
					}).reload()
				},
				doSearch() {
					this.showLoading()
					this.list.setData({
						_order: {
							id: "DESC"
						},
						_where:this.where,
						_search:this.text,
						_g:['report','user','job'],
						_range:['all']
					}).reload()
				},
				deleteIt(id){
					this.$api.delete('/api/cimingReports/' + id ,{},res=>{
						this.reload()
					})
				}
		},
		mounted() {
			this.list.initMescroll(this).setUrl('/api/cimingReports').setData({
				_order: {
					id: "DESC"
				},
				_where:this.where,
				_search:this.text,
				_g:['report','user','job'],
				_range:['all']
			}).setCbFunc(res => {
				this.data = res
				this.clearLoading()
			}).reload()
		},
		onLoad(option) {
			
		},
		onShow() {
			this.reload()
		}
	}
</script>

<style>

</style>
